# -*- coding: utf-8 -*-
# @Time : 2021/9/16 21:55
# @Author : Mr  jelis
# @Email : 1402615849@qq.com
# @File : MRSX-ST-CUXIAO-003.py
# @Project : app_test
"""删除购物车商品"""
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy as By
from time import sleep

desired_capabilities={
    "platformName":"Android",
    "deviceName":"127.0.0.1:62001",
    "platformVersion":"7.1.2",
    "appPackage":" cn.missfresh.application",
    "appActivity":"cn.missfresh.module.main.view.MainActivity",
    "noReset":True
}
driver=webdriver.Remote("http://localhost:4723/wd/hub",desired_capabilities)

mid_autumn_locator=(By.XPATH,'//android.widget.ImageView[@resource-id=\"cn.missfresh.application:id/iv_topview\"]')

add_shopping_locator=(By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/'
                               'android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/'
                               'android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout/'
                               'android.widget.LinearLayout/android.widget.FrameLayout/android.webkit.WebView/'
                               'android.webkit.WebView/android.view.View/android.view.View[3]/android.view.View[2]/'
                               'android.view.View[2]/android.view.View[5]/android.view.View/android.widget.Image')
enter_shopping_locator=(By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/'
                                 'android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/'
                                 'android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout/'
                                 'android.widget.LinearLayout/android.widget.FrameLayout/android.webkit.WebView/'
                                 'android.webkit.WebView/android.view.View/android.view.View[4]/android.view.View/android.widget.Image')
delete_locator=(By.XPATH,'//android.view.View[@content-desc=\"删除\"]')
sure_locator=(By.XPATH,'//android.widget.TextView[@resource-id=\"cn.missfresh.application:id/tv_ensure\"]')
sleep(3)
driver.find_element(*mid_autumn_locator).click()
sleep(3)
driver.find_element(*add_shopping_locator).click()
sleep(3)
driver.find_element(*enter_shopping_locator).click()
sleep(3)
driver.find_element(*delete_locator).click()
sleep(3)
driver.find_element(*sure_locator).click()
sleep(10)
driver.quit()